home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 10.7 KB | 358 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWMnuItm.h
- // Release Version: $ 1.0d11 $
- //
- // Copyright: © 1993, 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWMNUITM_H
- #define FWMNUITM_H
-
- #ifndef FWMENU_K
- #include "FWMenu.k"
- #endif
-
- #ifndef FWMNUBAR_H
- #include "FWMnuBar.h"
- #endif
-
- // ----- Foundation Includes -----
-
- #ifndef FWSTRS_H
- #include "FWStrs.h"
- #endif
-
- #ifndef FWSTREAM_H
- #include "FWStream.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef _ODTYPES_
- #include <ODTypes.h>
- #endif
-
- #ifndef SOM_Module_OpenDoc_Commands_defined
- #include <CmdDefs.xh>
- #endif
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- //========================================================================================
- // Forward Class Declarations
- //========================================================================================
-
- class FW_CLASS_ATTR FW_CPullDownMenu;
- class FW_CLASS_ATTR FW_CString;
- class FW_CLASS_ATTR FW_CMenuBar;
-
- //========================================================================================
- // class FW_CMenuItem
- //========================================================================================
-
- class FW_CLASS_ATTR FW_CMenuItem
- {
- public:
- FW_DECLARE_CLASS
-
- //----------------------------------------------------------------------------------------
- // Constructors/Destructors
- //
- public:
- // FW_CMenuItem();
- FW_CMenuItem(Environment* ev,
- FW_CReadableStream& archive);
- FW_CMenuItem(Environment* ev,
- FW_CPullDownMenu* ownerMenu,
- short index);
-
- virtual ~FW_CMenuItem();
-
- //----------------------------------------------------------------------------------------
- // New API
- //
- public:
- //----- Getters/setters -----
- virtual void GetItemText(Environment* ev, FW_CString& itemText) const;
- ODCommandID GetCommandID(Environment* ev) const;
- virtual FW_MenuKey GetMenuKey(Environment* ev) const;
-
- FW_CPullDownMenu* GetOwnerMenu(Environment* ev) const;
- short GetIndex(Environment* ev) const;
-
- //----- Archiving -----
- virtual void Flatten(Environment* ev, FW_CWritableStream& archive);
- static void* Read(FW_CReadableStream& archive);
- static void Write(FW_CWritableStream& archive, const void* theMenuItem);
-
- //----------------------------------------------------------------------------------------
- // Implementation only
- //
- public:
- virtual void PrivAttach(Environment* ev, FW_CMenuBar* menuBar);
- virtual void PrivDetach(Environment* ev, FW_CMenuBar* menuBar);
- virtual void PrivDisableAll(Environment* ev);
- virtual void PrivEnableAll(Environment* ev);
- virtual FW_CMenuItem* PrivGetMenuItem(Environment* ev, ODCommandID commandID) const;
-
- virtual FW_CPullDownMenu* PrivFindMenuWithID(Environment* ev, ODMenuID menuID) const;
-
- void PrivSetIndex(Environment* ev, short newIndex);
-
- //----------------------------------------------------------------------------------------
- // Data Members
- //
- protected:
- #ifdef FW_BUILD_MAC
- ODCommandID fCommandID; // On windows call the toolbox
- #endif
- FW_CPullDownMenu* fOwnerMenu;
- short fIndex; // one-based
- };
-
- //========================================================================================
- // class FW_CSeparatorItem
- //========================================================================================
-
- class FW_CLASS_ATTR FW_CSeparatorItem : public FW_CMenuItem
- {
- public:
- FW_DECLARE_CLASS
-
- //----------------------------------------------------------------------------------------
- // Constructors/Destructors
- //
- public:
- // FW_CSeparatorItem();
- FW_CSeparatorItem(Environment* ev,
- FW_CReadableStream& archive);
- FW_CSeparatorItem(Environment* ev,
- FW_CPullDownMenu* ownerMenu,
- short index);
-
- virtual ~FW_CSeparatorItem();
-
- protected:
- void InitSeparator(Environment* ev, const ODPlatformMenu& platformMenu);
-
- //----------------------------------------------------------------------------------------
- // Inherited API
- //
- public:
- static void* Read(FW_CReadableStream& archive);
-
- //----------------------------------------------------------------------------------------
- // Implementation only
- //
- public:
- virtual void PrivDisableAll(Environment* ev);
- virtual void PrivEnableAll(Environment* ev);
- };
-
- //========================================================================================
- // class FW_CTextItem
- //========================================================================================
-
- class FW_CLASS_ATTR FW_CTextItem : public FW_CMenuItem
- {
- public:
- FW_DECLARE_CLASS
-
- //----------------------------------------------------------------------------------------
- // Constructors/Destructors
- //
- public:
- // FW_CTextItem();
- FW_CTextItem(Environment* ev,
- FW_CReadableStream& archive);
- FW_CTextItem(Environment* ev,
- FW_CPullDownMenu* ownerMenu,
- short index,
- const FW_CString& text,
- ODCommandID commandID,
- FW_MenuKey menuKey = FW_kNoKeyEquivalent);
- virtual ~FW_CTextItem();
-
- //----------------------------------------------------------------------------------------
- // Inherited API
- //
- public:
- //----- Getters/setters -----
- virtual void GetItemText(Environment* ev, FW_CString& itemText) const;
- virtual FW_MenuKey GetMenuKey(Environment* ev) const;
-
- //----- Archiving -----
- virtual void Flatten(Environment* ev, FW_CWritableStream& archive);
- static void* Read(FW_CReadableStream& archive);
-
- //----------------------------------------------------------------------------------------
- // New API
- //
- public:
- virtual void SetItemText(Environment* ev, const FW_CString& itemText) const;
-
- //----------------------------------------------------------------------------------------
- // Implementation only
- //
- public:
- #ifdef FW_BUILD_MAC
- virtual void PrivAttach(Environment* ev, FW_CMenuBar* menuBar);
- virtual void PrivDetach(Environment* ev, FW_CMenuBar* menuBar);
- #endif
- private:
- void PrivInitTextItem(Environment* ev,
- const ODPlatformMenu& platformMenu,
- const FW_CString& text,
- ODCommandID commandID,
- FW_MenuKey menuKey);
-
- };
-
- //========================================================================================
- // class FW_CToggleItem
- //========================================================================================
-
- class FW_CLASS_ATTR FW_CToggleItem : public FW_CTextItem
- {
- public:
- FW_DECLARE_CLASS
-
- //----------------------------------------------------------------------------------------
- // Constructors/Destructors
- //
- public:
- // FW_CToggleItem();
- FW_CToggleItem(Environment* ev,
- FW_CReadableStream& archive);
- FW_CToggleItem(Environment* ev,
- FW_CPullDownMenu* ownerMenu,
- short index,
- const FW_CString& trueText,
- const FW_CString& falseText,
- ODCommandID commandID,
- FW_MenuKey menuKey = FW_kNoKeyEquivalent);
- virtual ~FW_CToggleItem();
-
- //----------------------------------------------------------------------------------------
- // New API
- //
- public:
- //----- Getters/setters -----
- void GetTrueText(Environment* ev, FW_CString& trueText) const;
- void GetFalseText(Environment* ev, FW_CString& falseText) const;
-
- void ToggleItem(Environment* ev, FW_Boolean newState);
-
- //----- Archiving -----
- virtual void Flatten(Environment* ev, FW_CWritableStream& archive);
- static void* Read(FW_CReadableStream& archive);
-
- //----------------------------------------------------------------------------------------
- // Data Members
- //
- private:
- FW_Boolean fToggleState;
- FW_CDynamicString fOtherText;
- };
-
- //========================================================================================
- // class FW_CSubMenuItem
- //========================================================================================
-
- class FW_CLASS_ATTR FW_CSubMenuItem : public FW_CMenuItem
- {
- public:
- FW_DECLARE_CLASS
-
- //----------------------------------------------------------------------------------------
- // Constructors/Destructors
- //
- public:
- // FW_CSubMenuItem();
- FW_CSubMenuItem(Environment* ev,
- FW_CReadableStream& archive);
- FW_CSubMenuItem(Environment* ev,
- FW_CPullDownMenu* ownerMenu,
- short index,
- FW_CPullDownMenu* adoptSubMenu);
- virtual ~FW_CSubMenuItem();
-
- //----------------------------------------------------------------------------------------
- // New API
- //
- public:
- //----- Getters/setters -----
- FW_CPullDownMenu* GetSubMenu(Environment* ev) const;
-
- //----- Archiving -----
- virtual void Flatten(Environment* ev, FW_CWritableStream& archive);
- static void* Read(FW_CReadableStream& archive);
-
- //----------------------------------------------------------------------------------------
- // Implementation only
- //
- public:
- virtual void PrivAttach(Environment* ev, FW_CMenuBar* menuBar);
- virtual void PrivDetach(Environment* ev, FW_CMenuBar* menuBar);
- virtual void PrivDisableAll(Environment* ev);
- virtual void PrivEnableAll(Environment* ev);
- virtual FW_CMenuItem* PrivGetMenuItem(Environment* ev, ODCommandID commandID) const;
-
- virtual FW_CPullDownMenu* PrivFindMenuWithID(Environment* ev, ODMenuID menuID) const;
-
- private:
- void PrivInitSubMenu(Environment* ev, const ODPlatformMenu& platformMenu);
-
- //----------------------------------------------------------------------------------------
- // Data Members
- //
- private:
- FW_CPullDownMenu* fSubMenu;
- };
-
- //========================================================================================
- // FW_CMenuItem inlines
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CMenuItem::GetOwnerMenu
- //----------------------------------------------------------------------------------------
- inline FW_CPullDownMenu* FW_CMenuItem::GetOwnerMenu(Environment* ev) const
- {
- return fOwnerMenu;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMenuItem::GetIndex
- //----------------------------------------------------------------------------------------
- inline short FW_CMenuItem::GetIndex(Environment* ev) const
- {
- return fIndex;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CSubMenuItem::GetSubMenu
- //----------------------------------------------------------------------------------------
- inline FW_CPullDownMenu* FW_CSubMenuItem::GetSubMenu(Environment* ev) const
- {
- return fSubMenu;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CMenuItem::PrivSetIndex
- //----------------------------------------------------------------------------------------
- inline void FW_CMenuItem::PrivSetIndex(Environment* ev, short newIndex)
- {
- fIndex = newIndex;
- }
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export off
- #endif
-
- #endif
-